package com.city.repository.party;

import com.city.domain.party.PartyStudentLesson;
import org.hibernate.annotations.SQLUpdate;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface PartyStudentLessonRepository extends JpaRepository<PartyStudentLesson,Integer> {

    //统计未完成课程数
    @Query(value = "select count(*) from party_student_lesson where student_id = ?1 and status = '0' ",nativeQuery = true)
    int countUnleaned(int studentId);

    //统计某学生的总课程数
    @Query(value = "select count(*) from party_student_lesson where student_id = ?1",nativeQuery = true)
    int countAllLesson(int studentId);

    //查询未完成课程id
    @Modifying
    @Query(value = "select lesson_id from party_student_lesson where student_id = ?1 and status = '0' ",nativeQuery = true)
    List<Integer> findIdsByStudenId(int studentId);

    //查询完成的课程id
    @Modifying
    @Query(value = "select lesson_id from party_student_lesson where student_id = ?1 and status = '1' ",nativeQuery = true)
    List<Integer> findHaveIdsByStudenId(int studentId);
}
